package com.holyn.guofang.utils;

import java.util.regex.Pattern;

/**
 * 注册、找回密码时，输入验证。
 * Created by Holyn on 2017/6/12.
 */

public class ValidUtil {
    /**
     * 是否包含字母
     */
    public static boolean isContainWord(String username) {
        Pattern pattern = Pattern.compile("[A-Za-z]+");
        return pattern.matcher(username).find();
    }

    /**
     * text 的长度是否大于 minLength
     */
    public static boolean isGreaterMinLength(int minLength, String text) {
        int length = text.trim().length();
        if (length >= minLength) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isTelephone(String moible) {
        String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9]))\\d{8}$";
        Pattern pattern = Pattern.compile(regex);
        return pattern.matcher(moible).matches();
    }

    public static boolean isEmail(String email) {
        String regex = "^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$";
        Pattern pattern = Pattern.compile(regex);
        return pattern.matcher(email).matches();
    }
}
